﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Collections.Specialized;
using Microsoft.Win32;

namespace Food
{
	class UserManager
	{
		static public string UsersFileName = "users.xml";

		
		public List<User> Users;

		public string CurrentUser
		{
			get 
			{
				RegistryKey regKey = Registry.CurrentUser.CreateSubKey(Config.RegistryLocation);

				return MiscHelper.GetParameterFromReg(regKey, "CurrentUser", string.Empty);
			}

			set
			{
				RegistryKey regKey = Registry.CurrentUser.CreateSubKey(Config.RegistryLocation);

				MiscHelper.SetParameterToReg(regKey, "CurrentUser", value);
			}
		}

		public UserManager()
		{
			Users = new List<User>();

			XmlDocument doc = new XmlDocument();

			doc.Load(Config.ServerBasePath + "\\" + UsersFileName);

			foreach(XmlNode userNode in doc.DocumentElement)
			{
				User newUser = new User(userNode);

				Users.Add(newUser);
			}

		}

	}
}
